<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="CHT模号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chtMoldNum">
              <a-input v-model="model.chtMoldNum" placeholder="请输入CHT模号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="螺杆种类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="screwType">
              <a-input v-model="model.screwType" placeholder="请输入螺杆种类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="建议螺杆直径" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="suggestedMachineScrewDiameter">
              <a-input v-model="model.suggestedMachineScrewDiameter" placeholder="请输入建议螺杆直径"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="射速需求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="requiredInjectionRate">
              <a-input v-model="model.requiredInjectionRate" placeholder="请输入射速需求"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="每模塑化的时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="timePerMolding">
              <a-input v-model="model.timePerMolding" placeholder="请输入每模塑化的时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="前模运水流动速率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cavityCicuitFlowRate">
              <a-input v-model="model.cavityCicuitFlowRate" placeholder="请输入前模运水流动速率"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="后模运水流动速率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="coreCicuitFlowRate">
              <a-input v-model="model.coreCicuitFlowRate" placeholder="请输入后模运水流动速率"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="浇口形式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gateType">
              <a-input v-model="model.gateType" placeholder="请输入浇口形式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="流道种类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="runnerType">
              <a-input v-model="model.runnerType" placeholder="请输入流道种类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="顶出方案" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ejectorScheme">
              <a-input v-model="model.ejectorScheme" placeholder="请输入顶出方案"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="热流道品牌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hotRunnerBrand">
              <a-input v-model="model.hotRunnerBrand" placeholder="请输入热流道品牌"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="热咀数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="numberOfHotNozzle">
              <a-input v-model="model.numberOfHotNozzle" placeholder="请输入热咀数量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="热咀形式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hotNozzleType">
              <a-input v-model="model.hotNozzleType" placeholder="请输入热咀形式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="达到顶出温度时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="timeToReachEjectionTemp">
              <a-input v-model="model.timeToReachEjectionTemp" placeholder="请输入达到顶出温度时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="开合模时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="openingAndClosingDieTime">
              <a-input v-model="model.openingAndClosingDieTime" placeholder="请输入开合模时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="取产品时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productPickUpTime">
              <a-input v-model="model.productPickUpTime" placeholder="请输入取产品时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模胚尺寸" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldBaseSize">
              <a-input v-model="model.moldBaseSize" placeholder="请输入模胚尺寸"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模具种类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldBaseType">
              <a-input v-model="model.moldBaseType" placeholder="请输入模具种类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="机械手种类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="manipulatorType">
              <a-input v-model="model.manipulatorType" placeholder="请输入机械手种类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模具温控箱" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tempControlBox">
              <a-input v-model="model.tempControlBox" placeholder="请输入模具温控箱"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模温机" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldTemperatureMachine">
              <a-input v-model="model.moldTemperatureMachine" placeholder="请输入模温机"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="手掌(EOAT）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="eoat">
              <a-input v-model="model.eoat" placeholder="请输入手掌(EOAT）"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="成型机台型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldingMachineModel">
              <a-input v-model="model.moldingMachineModel" placeholder="请输入成型机台型号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="成型吨位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="machineTonnage">
              <a-input v-model="model.machineTonnage" placeholder="请输入成型吨位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="注塑机容模尺寸（长宽高）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="injectionMoldingMachineSize">
              <a-input v-model="model.injectionMoldingMachineSize" placeholder="请输入注塑机容模尺寸（长宽高）"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="成型周期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldingCycle">
              <a-input v-model="model.moldingCycle" placeholder="请输入成型周期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="穴数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cavities">
              <a-input v-model="model.cavities" placeholder="请输入穴数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模具难度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldDifficulty">
              <a-input v-model="model.moldDifficulty" placeholder="请输入模具难度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="流道重量/穴" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="runnerWeight">
              <a-input v-model="model.runnerWeight" placeholder="请输入流道重量/穴"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="流道总重量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="runnerTotalWeight">
              <a-input v-model="model.runnerTotalWeight" placeholder="请输入流道总重量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="产品单重/穴" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partWeight">
              <a-input v-model="model.partWeight" placeholder="请输入产品单重/穴"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="总重量/模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="oneShotTotalWeight">
              <a-input v-model="model.oneShotTotalWeight" placeholder="请输入总重量/模"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="炮筒最大射出量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maxVolumeOfBarrelShot">
              <a-input v-model="model.maxVolumeOfBarrelShot" placeholder="请输入炮筒最大射出量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="射胶量百分比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="injectionPercentage">
              <a-input v-model="model.injectionPercentage" placeholder="请输入射胶量百分比"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="料筒停留时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="barrelResidenceTime">
              <a-input v-model="model.barrelResidenceTime" placeholder="请输入料筒停留时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模具寿命" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldLife">
              <a-input v-model="model.moldLife" placeholder="请输入模具寿命"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="热嘴套钢料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hotNozzleSleeveSteel">
              <a-input v-model="model.hotNozzleSleeveSteel" placeholder="请输入热嘴套钢料"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="前模芯钢料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cavitySteel">
              <a-input v-model="model.cavitySteel" placeholder="请输入前模芯钢料"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="推套钢料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pushRingSteel">
              <a-input v-model="model.pushRingSteel" placeholder="请输入推套钢料"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="后模芯钢料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="coreSteel">
              <a-input v-model="model.coreSteel" placeholder="请输入后模芯钢料"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模胚形式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="moldType">
              <a-input v-model="model.moldType" placeholder="请输入模胚形式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="其他配件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="others">
              <a-input v-model="model.others" placeholder="请输入其他配件"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'MoldBasicInformationForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 13 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/ch/moldBasicInformation/add",
          edit: "/ch/moldBasicInformation/edit",
          queryById: "/ch/moldBasicInformation/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>